package com.yznote.cloudesk.common.exception;

import com.yznote.cloudesk.common.pojo.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Wangzurong
 * @create 2022-07-23 16:13
 * 全局异常处理器
 */
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    @ResponseBody
    public Result error(Exception e) {
        e.printStackTrace();
        return Result.build(null,600,"未知异常:"+e.getMessage());
    }

    @ExceptionHandler(YException.class)
    @ResponseBody
    public Result YError(YException e) {
        e.printStackTrace();


        return Result.build(null,600,e.getMessage());
    }
}
